From f165c38c37f68139355b8dcabb4948338931874f Mon Sep 17 00:00:00 2001 From: oliskoli Date: Wed, 5 Apr 2006 22:26:57 +0000 Subject: [PATCH] Fix calculation of course (diff. between 32- and 64-bit system). --- gpsbabel/garmin_txt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gpsbabel/garmin_txt.c b/gpsbabel/garmin_txt.c index 072f7c5ef..512981b2c 100644 --- a/gpsbabel/garmin_txt.c +++ b/gpsbabel/garmin_txt.c @@ -292,7 +292,11 @@ distance(double lat1, double lon1, double lat2, double lon2) /* nearly MapSource static double course_rad(double lat1, double lon1, double lat2, double lon2) { - return mod(atan2(sin(lon1 - lon2) * cos(lat2), cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(lon1-lon2)), 2 * M_PI); + double v1, v2; + v1 = sin(lon1 - lon2) * cos(lat2); + v2 = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(lon1 - lon2); + if (fabs(v2) < 0.000000000000001) v2 = 0.0; /* fix calculation diff. between 32- and 64-bit systems */ + return atan2(v1, v2); } static double -- 2.30.2